package com.entor.sevice.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.entor.dao.CirclesDao;
import com.entor.model.Pupil;
import com.entor.sevice.CirclesServiceI;
import com.entor.util.ComboTree;
@Service
public class CirclesServiceImpl implements CirclesServiceI {
	
	@Autowired
	private CirclesDao cd;

	public List<Pupil> find(Pupil t) {
		return cd.find(t);
	}

	public int insert(Pupil t) {
		return cd.insert(t);
	}

	public int update(Pupil t) {
		return cd.update(t);
	}

	public int delete(String id) {
		return cd.delete(id);
	}

	public List<ComboTree> treeFind(Pupil circles) {
		List<Pupil> list = cd.treeFind(circles);
		List<ComboTree> li = new ArrayList<ComboTree>();
		ComboTree ct = new ComboTree();
		ct.setId(0);
		ct.setName("全部");
		ct.setParentId(null);
		li.add(ct);
		for(Pupil g:list){
			ct = new ComboTree();
			ct.setName(g.getName());
			ct.setParentId(0);
			li.add(ct);
			/*ClassGrade t = new ClassGrade();
			t.setCirclesId(g.getId());
			List<ClassGrade> cgList = cgd.find(t);
			for(ClassGrade cg :cgList){
				ct = new ComboTree();
				ct.setId(cg.getId());
				ct.setName(cg.getClassName());
				ct.setParentId(cg.getCirclesId());
				li.add(ct);
			}*/
		}
		return li;
	}
	public List<ComboTree> comboTree(Pupil circles) {
		List<Pupil> list = cd.find(circles);
		List<ComboTree> li = new ArrayList<ComboTree>();
		ComboTree ct = new ComboTree();
		ct.setId(0);
		ct.setName("全部");
		ct.setParentId(null);
		li.add(ct);
		for(Pupil g:list){
			ct = new ComboTree();
			ct.setName(g.getName());
			ct.setParentId(0);
			li.add(ct);
			
		}
		return li;
	}

	

}
